Skip to content

Slicer update (C++ and bindings) - #67

Open
hschreiber wants to merge 14 commits into
DavidLapous:mainfrom
hschreiber:update_from_gudhi
Open

Slicer update (C++ and bindings)#67
hschreiber wants to merge 14 commits into
DavidLapous:mainfrom
hschreiber:update_from_gudhi

Conversation

@hschreiber

Copy link
Copy Markdown
Contributor

I went through the whole Slicer bindings to add the functionalities missing in the backend C++ Slicer. At the same occasion I reorganized the bindings, here a few comments about it:

  • _slicer_nanobind.cpp is now decomposed in three file (2 headers). This is meant to be temporary. It helped me organizing the different binding types done in this file and at the end to separate what I modified and what not. There will be a follow up PR where I unify everything again.
  • The compile time went up. Perhaps because I don't compile separately SlicerConversion anymore or perhaps because of something else. We should think of a solution to avoid binding that many Slicers in the first place (perhaps by binding a single virtual Slicer instead and have a pointer factory to instantiate them with particular Slicers?). We could also compile the Slicer_interface classes separately as you did with SlicerConversion and Slicer to help parallelization.

@DavidLapous

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9210a71e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread multipers/gudhi/Slicer_interface.h Outdated
Comment thread multipers/_slicer_nanobind.h Outdated
Comment on lines +74 to +78
if (nanobind::isinstance<nanobind::iterable>(obj)) {
auto it = nanobind::cast<nanobind::iterable>(obj);
auto begin = it.begin();
if (begin != it.end()) return _get_dtype(*begin);
return Array_dtype::EMPTY;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve one-shot iterables while detecting their dtype

When an advertised iterable argument is a generator or iterator, calling begin() and dereferencing it here consumes its first item. The subsequent conversion of filtration_values therefore sees a missing first row (and nested one-shot row iterators similarly lose their first coordinate), causing shape failures or shifted filtration data; dtype inspection must either buffer the item or avoid iterating one-shot inputs twice.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really meant for iterables with one-shot iterators, but there is no satisfying way to rule them out. But as it will probably only be used by lists, tuples or tensors, I added the condition of existing __getitem__ and __len__ to be able to add a guard. It is just not satisfying. The real thing I would like to test here is "is it a range of something" and "can I have access to the first element several times", but I could not find a solution which always works for that...
And copying the container to ensure several accesses is out of question, as the containers can be huge. In particular as one-shot iterables are very unlikely to be ever used here.

Comment thread multipers/gudhi/slicer_interface_helpers.h Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants